package day05;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

//二进制补码打印 -6(10) = 11111111 11111111 11111111 11111010(2)
//~x=-(x+1)
public class DecToBinary {
    public static void main(String[] args) throws IOException {
        int n = -6;
        System.out.print(String.format("%d(10) =", n));
        //b31 b30 .... b0

        for (int i = 31; i >= 0; i--) {
            if (i % 8 == 7) System.out.print(" ");
            System.out.print((n >> i) & 1);

        }
        System.out.println(String.format("(2)", n));
        // System.out.println((n >> 8) & 0xffff);//取中间的2个字节

    }
}